﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for ContentHandler
/// </summary>
public class ContentHandler
{

    QuestionObject qObject;

    string[] tempQuestion;
    
    public ContentHandler(WebControl control)
	{
        if (control is RadioButton)
        {
            getQuestionObjectFromRadioButtonList();
        }
        else
        {
            getQuestionObjectFromTextBoxList();
        }
	}



    private void getQuestionObjectFromRadioButtonList()
    {
        foreach (var radioButton in Variables.checkedRadioButtonList)
        {
            qObject = new QuestionObject();
            tempQuestion = radioButton.ID.ToString().Split('_');
            ConvertToText convert = new ConvertToText(tempQuestion[0], tempQuestion[1]);
            Variables.questionListSymbol.Add(convert.getNewQuestionObject());
        }
    }

    private void getQuestionObjectFromTextBoxList()
    {
        foreach (var textBox in Variables.TextBoxList)
        {
            qObject = new QuestionObject();
           
            qObject.setColumName(textBox.ID);
            qObject.setValue(textBox.Text);
            Variables.questionListSymbol.Add(qObject);
        }
    }

    
}